//
// file : ipctest.cpp
// date : 09/17/07
//
// 
#include <stdio.h>
#include <string.h>
#include <time.h>

#include "inet_ipc.h"
#include "inet_apc.h"


///* - timer test

void __stdcall my_timer(struct utimer_t *tb)
{
    ipc_print(" [%d] my_timer ticks=%d delay=%d\n", tick_count(), tb->ut_ticks, tb->ut_delay);
}

int main(int argc, char *argv[])
{
    long didx;
    long sid;

ipc_print(" [%d] start..\n", tick_count());

    //didx = ipc_startup(5, 0);  // no heart beat
    didx = ipc_startup(5, 100);  // heart beat 100 ms

    sid  = ipc_session(didx, 0);

    utimer_t  ut;

    memset(&ut, 0, sizeof(ut));

    ut.ut_delay = 900;
    ut.ut_awake = my_timer;
    ipc_loadtmr(sid, &ut);

    ut.ut_delay = 2000;
    ut.ut_awake = my_timer;
    ipc_loadtmr(sid, &ut);

    sleep(1);

    ut.ut_delay = 1000;
    ut.ut_awake = my_timer;
    ipc_loadtmr(sid, &ut);

    sleep(6);

    ipc_shutoff(sid);

    ipc_cleanup( didx );

    printf(" (%s) didx=%d sid=(%d %d) exit\n", argv[0], (int)didx, HIWORD(sid), LOWORD(sid) );

    return 0;
}

